﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Xms.Abp.Core;

namespace Xms.Abp.Domain.Repositories;

public interface IXmsReadOnlyBasicRepository<TEntity> : IReadOnlyBasicRepository<TEntity>
    where TEntity : class, IEntity
{
    [Obsolete("Use AsNoTrackingAsync() method.")]
    IQueryable<TEntity> AsNoTracking();
    Task<IQueryable<TEntity>> AsNoTrackingAsync();
    [Obsolete("Use AsTrackingAsync() method.")]
    IQueryable<TEntity> AsTracking();
    Task<IQueryable<TEntity>> AsTrackingAsync();
    [Obsolete("Use AttachAsync() method.")]
    void Attach(TEntity entity);
    Task AttachAsync(TEntity entity);
    [Obsolete("Use AttachAsync() method.")]
    void Attach(IEnumerable<TEntity> entities);
    Task AttachAsync(IEnumerable<TEntity> entities);
    Task<IQueryable<TEntity>> IncludeAsync<TProperty>(Expression<Func<TEntity, TProperty>> navigationPropertyPath);
    Task<IQueryable<TEntity>> IncludeAsync<TProperty>(string navigationPropertyPath);
}

public interface IXmsReadOnlyRepository<TEntity> :
    IReadOnlyRepository<TEntity>,
    IXmsReadOnlyBasicRepository<TEntity>
    where TEntity : class, IEntity
{
    Task<IQueryable<TEntity>> GetQueryAsync(string sql, params object[] parameters);
}

public interface IXmsBasicRepository<TEntity> :
    IBasicRepository<TEntity>,
    IXmsReadOnlyBasicRepository<TEntity>
    where TEntity : class, IEntity
{
    Task DeleteManyAsync(Expression<Func<TEntity, bool>> predicate, bool autoSave = false, CancellationToken cancellationToken = default);
    Task UpdateManyAsync(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, TEntity>> updateFactory, Action<TEntity> updateAction, bool autoSave = false, CancellationToken cancellationToken = default);
    Task UpdateManyAsync(Expression<Func<TEntity, bool>> predicate, Dictionary<string, object> values, Action<TEntity> updateAction, bool autoSave = false, CancellationToken cancellationToken = default);
}

public interface IXmsRepository<TEntity> :
    IRepository<TEntity>,
    IXmsReadOnlyRepository<TEntity>,
    IXmsBasicRepository<TEntity>
    where TEntity : class, IEntity
{

}

public interface IXmsReadOnlyBasicRepository<TEntity, TKey> :
    IReadOnlyBasicRepository<TEntity, TKey>,
    IXmsReadOnlyBasicRepository<TEntity>
    where TEntity : class, IEntity<TKey>
{

}

public interface IXmsReadOnlyRepository<TEntity, TKey> :
    IReadOnlyRepository<TEntity, TKey>,
    IXmsReadOnlyBasicRepository<TEntity, TKey>,
    IXmsReadOnlyRepository<TEntity>
    where TEntity : class, IEntity<TKey>
{
}

public interface IXmsBasicRepository<TEntity, TKey> :
    IBasicRepository<TEntity, TKey>,
    IXmsReadOnlyBasicRepository<TEntity, TKey>,
    IXmsBasicRepository<TEntity>
    where TEntity : class, IEntity<TKey>
{

}

public interface IXmsRepository<TEntity, TKey> :
    IRepository<TEntity, TKey>,
    IXmsRepository<TEntity>,
    IXmsReadOnlyRepository<TEntity, TKey>,
    IXmsBasicRepository<TEntity, TKey>
    where TEntity : class, IEntity<TKey>
{

}
